//
//  SecondViewController.m
//  UI08_3_页面间传值(协议传值)
//
//  Created by Scott on 15/4/29.
//  Copyright (c) 2015年 www.lanou3g.com 蓝欧3G. All rights reserved.
//

#import "SecondViewController.h"

@interface SecondViewController ()

@property (nonatomic, retain) UITextField *textField;

@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 100, 300, 40)];
    self.textField.borderStyle = 3;
    self.textField.placeholder = @"请输入用户名";
    [self.view addSubview:self.textField];
    [_textField release];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(20, 200, 300, 40);
    [button setTitle:@"确定" forState:UIControlStateNormal];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    
}


- (void)buttonClicked:(UIButton *)button
{
#warning 协议传值: 3. 在合适的位置, 让指定代理人实现协议方法
    [self.delegate passValue:self.textField.text];
    [self.navigationController popToRootViewControllerAnimated:YES];
}



- (void)dealloc
{
    [_textField release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
